﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DroidClaim.BL;
using DroidClaimBL.Dto;
using Utility;
using DroidClaim.BL.Dto;

namespace DroidClaimTest
{
    class Program
    {
        /*
        ResultBlDto RegisterCustomer(CustomerBlDto customerDto);
        ResultBlDto RegisterSurveyor(SurveyorBlDto surveyorDto);
        AuthenCustomerResultBlDto AuthenCustomer(AuthenCustomerBlDto authenCustomer);
        ClaimRequestResultBlDto AddClaimRequest(ClaimRequestBlDto claimRequest);
        List<ClaimInfoBlDto> GetAllClaimInfoForCustomer(SessionPkBlDto sessionPk);
        bool Logout(SessionPkBlDto SessionPk);
        AuthenSurveyorResultBlDto AuthenSurveyor(AuthenSurveyorBlDto authenSurveyor);
        UpdateSurveyorStatusResultBlDto UpdateSurveyorStatus(SurveyorStatusBlDto status);
        UpdateSurveyorLocationResultBlDto UpdateSurveyorLocation(SurveyorLocationBlDto status);
        SurveyorLocationResultBlDto GetSurveyorLocation(ClaimInfoPKBlDto cliamInfoPk);
        ClaimInfoForSurveyorResultBlDto GetClaimInfoForSurveyor(ClaimInfoPKBlDto cliamInfoPk);
        DenyMessageResultBlDto SendDenyMessage(DenyMessageBlDto denyMessage);
        ClaimIdResultBlDto UpdateClaim(UpdateClaimInfoBlDto updateClaimInfo);
        CustomerBlDto GetCustomer();
        */
        private String sessionId = "";
        private int claimId = -1;
        private int surveyorId = -1;

        static void Main(string[] args)
        {
            Program test = new Program();


            //test.RegisterCustomer();
            test.AuthenCustomer();
            test.AddClaimRequest();
            //test.GetCliamInfoForCustomer();
            
            //test.GetAllClaimInfoForCustomer();

            //test.RegisterSurveyor();
            test.AuthenSurveyor();
            //test.UpdateSurveyorStatus();
            //test.UpdateSurveyorLocation();
            test.SendAcceptMessage();
            //test.SendDenyMessage();
            //test.GetCliamInfoForSurveyor();
            //test.GetSurveyorLocation();
            //test.UpdateClaim();

            //test.Logout();
        }

        void UpdateClaim()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            UpdateClaimInfoBlDto dto = new UpdateClaimInfoBlDto();
            dto.SessionId = sessionId;
            dto.ClaimId = claimId;
            string imageStr = ServerFileHandle.GetImageString(@"C:\DroidClaim\ClaimDoc.jpeg");
            dto.ClaimDocImage = imageStr;
            ClaimIdResultBlDto result = bl.UpdateClaim(dto);
        }

        void GetCliamInfoForSurveyor()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            ClaimInfoPKBlDto dto = new ClaimInfoPKBlDto();
            dto.SessionId = sessionId;
            dto.Id = claimId;
            ClaimInfoForSurveyorResultBlDto result = bl.GetClaimInfoForSurveyor(dto);
        }

        void GetCliamInfoForCustomer()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            ClaimInfoPKBlDto dto = new ClaimInfoPKBlDto();
            dto.SessionId = sessionId;
            dto.Id = claimId;
            ClaimInfoForCustomerResultBlDto result = bl.GetClaimInfoForCustomer(dto);
        }

        void SendDenyMessage()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            DenyMessageBlDto dto = new DenyMessageBlDto();
            dto.SessionId = sessionId;
            dto.ClaimId = claimId;
            dto.DenyReason = "ติดธุระด่วน";
            DenyMessageResultBlDto result = bl.SendDenyMessage(dto);
        }

        void SendAcceptMessage()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            AcceptMessageBlDto dto = new AcceptMessageBlDto();
            dto.SessionId = sessionId;
            dto.ClaimId = claimId;
            AcceptMessageResultBlDto result = bl.SendAcceptMessage(dto);            
        }

        void GetSurveyorLocation()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            ClaimInfoPKBlDto dto = new ClaimInfoPKBlDto();
            dto.SessionId = sessionId;
            dto.Id = surveyorId;
            SurveyorLocationResultBlDto result = bl.GetSurveyorLocation(dto);
            double lattitude = result.Latitude;
            double longitude = result.Longitude;
        }

        void Logout()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            SessionPkBlDto dto = new SessionPkBlDto();
            dto.SessionId = sessionId;
            bool result = bl.Logout(dto);
        }

        void GetAllClaimInfoForCustomer()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            SessionPkBlDto dto = new SessionPkBlDto();
            dto.SessionId = sessionId;
            AllClaimInfoForCustomerResultBlDto result = bl.GetAllClaimInfoForCustomer(dto);
            // public bool Result { get; set; }
            // public String ErrorMsg { get; set; }
            // public List<ClaimInfoBlDto> ClaimInfoList { get; set; }
        }

        void UpdateSurveyorLocation()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            SurveyorLocationBlDto dto = new SurveyorLocationBlDto();
            dto.SessionId = sessionId;
            dto.Status = true;
            dto.Latitude = 13.770280;
            dto.Longitude = 100.653670;
            UpdateSurveyorLocationResultBlDto result = bl.UpdateSurveyorLocation(dto);
        }

        void UpdateSurveyorStatus()
        {
            IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
            SurveyorStatusBlDto dto = new SurveyorStatusBlDto();
            dto.SessionId = sessionId;
            dto.Status = true;
            dto.Latitude = 13.770280;
            dto.Longitude = 100.653670;
            UpdateSurveyorStatusResultBlDto result = bl.UpdateSurveyorStatus(dto);
        }

        void AddClaimRequest()
        {
            try
            {
                IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
                ClaimRequestBlDto dto = new ClaimRequestBlDto();
                dto.SessionId = sessionId;
                string imageStr =  ServerFileHandle.GetImageString(@"C:\DroidClaim\claimrequest.jpg");
                dto.AccImg = imageStr;
                dto.Latitude = 13.770280;
                dto.Longitude = 100.653670;
                dto.Location = "สถาบันบัณฑิตพัฒนบริหารศาสตร์(นิด้า)";
                ClaimRequestResultBlDto result = bl.AddClaimRequest(dto);
                claimId = result.ClaimInfoId;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        void AuthenSurveyor()
        {
            try
            {
                IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
                AuthenSurveyorBlDto dto = new AuthenSurveyorBlDto();
                dto.Username = "s124";
                dto.Password = "1234";
                dto.NoSurveyorData = true;
                dto.RegistrationId = "";
                AuthenSurveyorResultBlDto result = bl.AuthenSurveyor(dto);
                sessionId = result.SessionId;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        void RegisterSurveyor()
        {
            try
            {
                IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
                //DroidClaimBLClient bl = new DroidClaimBLClient();
                RegisterSurveyorBlDto dto = new RegisterSurveyorBlDto();
                dto.SurveyerId = "s124";
                dto.Username = "s124";
                dto.Password = "1234";
                dto.Name = "Robert";
                dto.Surname = "Vigo";
                dto.Mobile = "0855167866";
                dto.Email = "teenueng@gmail.com";
                dto.PicturePath = @"C:\DroidClaim\Surveyor.jpg";
                ResultBlDto result = bl.RegisterSurveyor(dto);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        void RegisterCustomer()
        {
            try
            {
                IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
                //DroidClaimBLClient bl = new DroidClaimBLClient();
                RegisterCustomerBlDto dto = new RegisterCustomerBlDto();
                dto.LicensePlate = "123";
                dto.Name = "Teerapong";
                dto.Surname = "Sansaneeyawat";
                dto.Mobile = "0858056696";
                dto.Email = "teenueng@gmail.com";
                dto.CustImgPath = @"C:\DroidClaim\Customer.jpg";
                dto.Password = "1234";
                dto.CarImgPath = @"C:\DroidClaim\CustomerCar.jpg";
                dto.CarBrand = "Toyota";
                dto.CarModel = "Camry";
                dto.InsurancePackage = "First Class";
                ResultBlDto result = bl.RegisterCustomer(dto);
            }catch(Exception ex){
                Console.WriteLine(ex.Message);
            }
        }

        void AuthenCustomer()
        {
            try
            {
                IDroidClaimBL bl = new DroidClaim.BL.DroidClaimBL();
                AuthenCustomerBlDto dto = new AuthenCustomerBlDto();
                dto.LicensePlate = "123";
                dto.Password = "1234";
                AuthenCustomerResultBlDto result = bl.AuthenCustomer(dto);
                sessionId = result.SessionId;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
